#ifndef __MSG_H_
#define __MSG_H_

#define MD5_LEN 16
#define MsgHead 0x76
#define MsgType 0x01
#define MsgVer 0x01

#define MaxSize 1024

struct HeadMsg
{
	int header;
	int version;
	int type;
	int length;
	char data[0];
};

char FCNIP[20];
char RouteID[40];
char ServerID[40];
char DiskPath[48];

int msg(void);
int analyze_msg(int sockfd, char *msg, int length);
int send_msg(int sockfd, char *data, int len);

int wan_set_pppoe(int sockfd, char *tagid, char *msg);
int wan_get_pppoe(int sockfd, char *tagid);
int wan_set_static(int sockfd, char *tagid, char *msg);
int wan_get_static(int sockfd, char *tagid);
int wan_set_dhcp(int sockfd, char *tagid, char *msg);
int wan_get_dhcp(int sockfd, char *tagid);

int wifi_set_ra0(int sockfd, char *tagid, char *msg);
int wifi_get_ra0(int sockfd, char *tagid);
int wifi_set_rai0(int sockfd, char *tagid, char *msg);
int wifi_get_rai0(int sockfd, char *tagid);
int wifi_set_ra1(int sockfd, char *tagid, char *msg);
int wifi_get_ra1(int sockfd, char *tagid);

int device_get_list(int sockfd, char *tagid);
int device_set_black(int sockfd, char *tagid, char *msg);
int device_get_blacklist(int sockfd, char *tagid);
int device_add_blacklist(int sockfd, char *tagid, char *msg);
int device_del_blacklist(int sockfd, char *tagid, char *msg);
int device_get_speedlimit(int sockfd, char *tagid, char *msg);
int device_set_speedlimit(int sockfd, char *tagid, char *msg);
int device_set_dhcp(char *ip, char *mac);

int system_key_error(int sockfd, char *tagid);
int system_register(int sockfd);
int system_register_response(int sockfd, char *tagid);
int system_ping(int sockfd);
int system_ping_response(int sockfd, char *tagid);
int system_get_wanspeed(int sockfd, char *tagid);
int system_get_wantatus(int sockfd, char *tagid);
int system_info(int sockfd, char *tagid);

int disk_set_share(int sockfd, char *tagid, char *msg);
int disk_get_share(int sockfd, char *tagid);
int disk_list_file(int sockfd, char *tagid, char *msg);
int disk_size_file(int sockfd, char *tagid);
int disk_rename_file(int sockfd, char *tagid, char *msg);
int disk_delete_file(int sockfd, char *tagid, char *msg);
int write_bytes(char *file, int index, char *data, int len);
int disk_write_file(int sockfd, char *tagid, char *msg);
int CharToHex(const char *src, unsigned char *dst, int len);
int read_bytes(int sockfd, char *tagid, int totalSize, char *fileId, char *filePath);
int disk_read_file(int sockfd, char *tagid, char *msg);

#endif
